Skip to content

Conversation

@jfhamlin
Copy link
Contributor

Summary

This PR addresses multiple compatibility issues discovered while running the Clojure test suite against Glojure, improving conformance with Clojure JVM behavior.

Major Changes

Core Language Features

  • case special form*: Complete refactor to properly handle hash collisions, particularly for false vs nil cases
  • Delay/Force: Added delay implementation with proper forcing semantics
  • Iterate: Implemented lazy iterate function for sequence generation
  • Exception handling: Added ExceptionInfo type and improved catch clause matching
  • Watches: Implemented watch functionality for both atoms and vars

Collections & Hashing

  • Hash consistency: Fixed hash computation for maps, sets, vectors, and lists to match Clojure
    • Vectors and lists now hash to the same value when containing equal elements
    • Maps compute hash as sum of (key XOR value) for each entry
    • Sets compute hash as sum of element hashes
  • Equality fixes: Improved lazy sequence equality checking
  • Interface corrections: Distinguished between Counted (constant-time) and Counter interfaces

Numeric Operations

  • Bit operations: Added missing bit-and-not, bit-set, bit-flip, bit-clear, and bit-test
  • Type casting: Fixed int and byte casting behavior to match JVM semantics
  • Number comparisons: Fixed edge cases in numeric operations

Function & Type Predicates

  • fn? predicate: Fixed to properly identify functions vs general IFn implementations
  • ifn? predicate: Corrected to match Clojure's behavior
  • contains?: Fixed for string type checking
  • Keyword comparison: Implemented proper Comparable interface for keywords

Runtime & Interop

  • Dynamic bindings: Fixed cloning of thread-local bindings for bound-fn
  • Namespace iteration: Use AllNamespaces() instead of direct access
  • Exception data: Added GetExData for exception info extraction
  • Next operation: Fixed next behavior for nil/empty sequences

Standard Library Updates

  • Updated core.glj transformations to handle new types and functions
  • Fixed hash-set implementation to use proper interop
  • Various stdlib fixes for test suite compatibility

Testing

  • Added comprehensive unit tests for case* analyzer
  • Added extensive tests for catch clause matching
  • Added hash consistency tests for collections
  • Successfully runs more of the Clojure test suite

Files Changed

  • Core language: 30+ files
  • Standard library: Multiple .glj files and loaders
  • Platform-specific imports: All architectures updated
  • Test files: New test coverage for critical paths

Breaking Changes

None expected - all changes improve compatibility with existing Clojure code.

Next Steps

  • Continue running Clojure test suite to identify remaining issues
  • Performance benchmarking of hash-based dispatch
  • Documentation updates for new features

Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Counted is only implemented by types with constant-time Count()
Counter is the simple interface for types with a Count() method

Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>

Fixes for case

Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
@jfhamlin jfhamlin marked this pull request as ready for review September 20, 2025 01:59
@jfhamlin jfhamlin merged commit 7276b43 into main Sep 20, 2025
2 checks passed
@jfhamlin jfhamlin deleted the fix/test-suite branch September 20, 2025 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants